<template>
  <view class="header">
    <!-- 左边 -->
    <div class="left" v-if="showLeft">
      <slot name="left">
        <uni-icons
          type="left"
          size="24"
          color="#ffffff"
          @click="onBack"
          class="arrow-left-icon"
        />
      </slot>
    </div>
    <text class="text">
      <slot />
    </text>

    <!-- 右边 -->
    <div class="right">
      <slot name="right" />
    </div>
  </view>
</template>

<script setup>
  const emit = defineEmits(['back']);

  const onBack = () => {
    emit('back');
  };

  const props = defineProps({
    showLeft: {
      type: Boolean,
      default: true,
    },
  });
</script>

<style lang="scss" scoped>
  .header {
    flex: 0 0 160rpx;
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 20rpx;
    padding: 84rpx 0 26rpx;
    height: 160rpx;
    color: #ffffff;
    background: linear-gradient(178deg, #e92232 0%, #f6843d 100%);

    .left {
      position: absolute;
      left: 30rpx;
      bottom: 24rpx;
    }

    .right {
      position: absolute;
      right: 30rpx;
      bottom: 24rpx;
    }

    .text {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;

      color: #ffffff;
      font-size: 36rpx;
      font-weight: 500;
      font-family: PingFangSC, PingFang SC;
    }
  }
</style>
